<?php

include_once("core/controller.php");
include_once("core/versionHandler.php");
/**
 * This Controller edits the rights file
 * @copyright inovia
 * @package oolime_manager
 *
 */
class editDispatcher extends Controller {

  function isLegitimate(){
    if(!$this->request->exist(Array("acl"))){
      return false;
    }
    
    $tabVerify = Array(
	    "acl"  => Array("string","Please enter a Dispatcher")
	  );
	  if( !$this->request->check($tabVerify)){
      $this->response->addError("Error in the Dispatcher","acl");
      return false;
    }
  
    return true;
  }
  
  function actions(){
    $success = true;
    try{
    include('core/libs/file.php');
      $config = new File("actions.php", "w");
      $config->writeAll(stripslashes($this->request->get('acl')));
      $config = null;
    }catch(Exception $e){
      $this->response->addError("Error in the Dispatcher writing","acl");
      $this->log->addError("Error in the Dispatcher writing");
      $success = false;
    }
    
    $node  	= $this->response->doc->createElement('message');
    if($success) $node->appendChild($this->response->doc->createTextNode("Dispatcher successfully updated"));
    else $node->appendChild($this->response->doc->createTextNode("Dispatcher update failed"));
    $this->response->add($node);
    
		include('controls/manager/formDispatcher.php');
		$this->response->setXSLT('views/manager/formDispatcher.xsl');
		new formDispatcher();
  }
  
  function defaultActions(){
		include('controls/manager/formDispatcher.php');
		$this->response->setXSLT('views/manager/formDispatcher.xsl');
		new formDispatcher();
  }
}
?>
